import openpyxl
from openpyxl.styles import Font
from openpyxl.styles import Alignment
import os
# 简单读取

file_path='C:\\Users\\wcj\\Desktop\\新建文件夹 (2)'
files=os.listdir(file_path)

a=0
def salarySum(filepath):
    global a
    workbook=openpyxl.load_workbook(filepath)

    sheet=workbook['Sheet1']
    colC=sheet['C']
    for i in colC:
        # print(i.value)
        try:    
            a=a+int(i.value)
        except:
            pass
    


def ru_kou():
    file_path='C:\\Users\\wcj\\Desktop\\新建文件夹 (2)'
    files=os.listdir(file_path)
    for i in files:
        salarySum(f'{file_path}\\{i}')
    print(a)
    return a


    



def gong_zi():
    workbook=openpyxl.Workbook()
    sheet=workbook.active
    
    align=Alignment(horizontal='center',vertical='center')
    
    sheet['A1']='总工资'
    sheet['A2']=ru_kou()
    
    sheet['A1'].alignment=align
    sheet['A2'].alignment=align
    
    workbook.save('E:\\123.xlsx')


gong_zi()